<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    #app {
      width: 100%;
      height: 150px;
    }

    .active {
      background-color: skyblue;
      color: white;
    }

    li {
      float: left;
      list-style-type: none;
      text-decoration: none;
      width: 100px;
      height: 100%;
    }

    a {
      text-decoration: none;
      color: black;
      width: 100px;
      display: inline-block;
      height: 30px;
      /* line-height: 50px; */
    }
  </style>
</head>

<body>

  <div id='app'>
    <ul>
      <li v-for="(item, index) in list" :key="item.id" @click="change(index)">
        <a :class="{ active: index == activeIndex}" href="#">{{item.name}}</a>
      </li>
    </ul>
  </div>
  <script src="../vue.js"></script>
  <script>
    const app = new Vue({
      el: '#app',
      data: {
        activeIndex: 0, // 记录高亮的下标
        list: [
          { id: 1, name: '京东秒杀' },
          { id: 2, name: '每日特价' },
          { id: 3, name: '品类秒杀' },
        ]
      },
      methods: {
        change(index) {
          this.activeIndex = index
        }
      }
    })
  </script>
</body>

</html>